<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 18/06/17
  Time: 15:49
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <title>查询结果页面</title>
    <script type="text/javascript" src="../js/jquery-3-2-1.js"></script>
    <link type="text/css" rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script type="text/javascript" src="../layui/layui.all.js"></script>
    <link type="text/css" rel="stylesheet" href="../css/style.css" media="all">
    <%	@SuppressWarnings("unchecked")
    List<Map<String,String>> obj = (List<Map<String,String>>) request.getAttribute("hxlist");
    String name = (String) request.getAttribute("name");
    String userid = (String) request.getAttribute("userid");
    String tkid = (String) request.getAttribute("tkid");
    int check=0;
    if(obj==null || obj.size()==0)
        check=1;
    %>
</head>
<body>
<%  int i=0;
    if(check==0) {
%>
    <table class="layui-table" lay-filter="tktable">
        <thead>
            <tr>
                <th lay-data="{field:'time',align:'center'}">时间</th>
                <th lay-data="{field:'HBH',align:'center'}">航班号</th>
                <th lay-data="{field:'plane',align:'center'}">飞机型号</th>
                <th lay-data="{field:'stjc',align:'center'}">出发机场</th>
                <th lay-data="{field:'enjc',align:'center'}">到达机场</th>
                <th lay-data="{fixed: 'right', align:'center', toolbar: '#barcity'}">操作</th>
            </tr>
        </thead>
        <tbody>
        <%
    String startjc=null;
    String endjc=null;
    String month=null;
    String day=null;
    for (Map<String, String> m : obj)
        {
            i++;
            startjc=m.get("stjcname");
            endjc=m.get("enjcname");
            month=m.get("month");
            day=m.get("day");
        %>
            <tr>
                <td><%=month%>.<%=day%></td>
                <td><%=m.get("HBH")%></td>
                <td><%=m.get("FJJX")%></td>
                <td><%=startjc%></td>
                <td><%=endjc%></td>
                <td></td>
            </tr>
        <%
        }
        %>
        </tbody>
        <%
    }
    else
        {
            %>

        <blockquote class="layui-elem-quote">暂时无满足条件的航班</blockquote>
        <div style="text-align: center;margin-left: 30%;margin-right: 30%">
            <a href="../buypg1.jsp"  class="layui-btn">跳转至查询页面</a>
        </div>
<%
    }
    %>
<script type="text/html" id="barcity">
    <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-xs" lay-event="buy">购买</a>
</script>
<script type="text/javascript">
    layui.use(['jquery','layer','table'], function(){
        var layer = layui.layer
            ,element = layui.element
            ,$= layui.$
            ,table=layui.table;

        //转换静态表格
        table.init('tktable', {limit: 10,page:true});
        //监听工具条
        table.on('tool(tktable)', function(obj) {
            var data = obj.data;
            var time = data['time'];
            var HBH = data['HBH'];
            var stjc = data['stjc'];
            var enjc = data['enjc'];
            var str = time.split(".");
            if (obj.event === 'buy') {
                window.location.href = "../buypg3.jsp?<%
                    if (name!=null){
                        out.print("name="+name + "&userid=" + userid + "&tkid=" + tkid + "&");
                    }
                %>HBH=" + HBH + "&stjc=" + stjc + "&enjc=" + enjc
                    + "&month=" + str[0] + "&day=" + str[1];
            }
        });
    });
</script>
</body>
</html>

